package com.example.juc.lock;

public class Demo1 {

    public static void main(String[] args) {
        Phone phone = new Phone();

        new Thread(phone::send,"A").start();

        new Thread(phone::send,"B").start();
    }
}


class Phone{

    public  synchronized void send(){
        System.out.println(Thread.currentThread().getName()+"->send");
        call();
    }


    public synchronized void call(){
        System.out.println(Thread.currentThread().getName()+"->call");
    }
}